<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<html>
<head>
	<style type="text/css">
		tr{height: 30px;}
		td{margin: 5px;padding: 5px;}
	</style>
<script type="text/javascript">
var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
	$(document).ready(function() {

		$('#roleName').focus();
		$.ajaxSetup({
			cache : false,
			async : false
		});
		//异步提交表单
		var options = {
			dataType : 'json',
			beforeSubmit : beforeSubmit,
			success : process
		};
		$("#roleForm").submit(function() {
			$(this).ajaxSubmit(options);
			return false;
		});

	});
	//提交前验证
	function beforeSubmit() {
		if (isEmpty($("#roleName").val())) {
			$.ligerDialog.alert("名称不能为空！");
			return false;
		}
		return true;
	}

	function process(responseJson) {
		if (responseJson.code == 0) {
			$.ligerDialog.error(responseJson.message);
			return;
		}
		window.parent.pagerForm.submit();
		dialog.close();
	}
</script>
</head>
<body>
	<div style="margin: 10px;">
		<form id="roleForm" method="post" action="role/insert.do">
			<table style="margin: 10px;">
				<tr>
					<td><label for="town">角色名称：</label></td>
					<td><input type="text" name="roleName" id="roleName" class="ldText" /></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>